// 深拷贝
const deepCopy = (function deepCopy(data){
    if(typeof data !== "object") return data;
    let obj = Array.isArray(data)? [] : {}
    for(let k in data){
         obj[k] = deepCopy(data[k])            
    }
    return obj    
})
// 判断数组是否存在某个对象
const ArrayIsObj = (array, obj) =>  {
    let arr = array.filter( v => {
        let isExist = true
        for(let k in v){
            if(v[k] !== obj[k]){
                isExist = false
            }
        }
        return isExist
    })
    return arr.length? true : false
}
const getS = (name) => {
    return JSON.parse(sessionStorage.getItem(name));
}
const setS = (name, value) => {
    sessionStorage.setItem(name, JSON.stringify(value))
}   
export default {
    getS,
    setS,
    deepCopy,
    ArrayIsObj
}